//
//  JZHMyNameViewController.m
//  极致荟
//
//  Created by hetao on 14-5-14.
//  Copyright (c) 2014年 mac. All rights reserved.
//

#import "JZHMyNameViewController.h"
#import "JZHImageView.h"
@interface JZHMyNameViewController ()

@property (weak, nonatomic) IBOutlet JZHImageView *image1;
@property (weak, nonatomic) IBOutlet JZHImageView *image2;
@property (weak, nonatomic) IBOutlet UIView *textview;
@property (weak, nonatomic) IBOutlet UIView *diview;

@end

@implementation JZHMyNameViewController
NSString *pusname;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

//根据请求页面来布局
- (JZHMyNameViewController *)initName:(NSString *)name
{
    JZHMyNameViewController *jzh=[[JZHMyNameViewController alloc]init];
    pusname=name;
       return jzh;
}
- (void)viewWillAppear:(BOOL)animated
{
    if([UIDevice currentDevice].systemVersion.floatValue > 6.5)
    {
        [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:93/255.0 green:190/255.0 blue:56/255.0 alpha:1]];
    }
    else
    {
        [self.navigationController.navigationBar setTintColor:[UIColor colorWithRed:93/255.0 green:190/255.0 blue:56/255.0 alpha:1]];
    }
    
//    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:93/255.0 green:190/255.0 blue:56/255.0 alpha:1]];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    if(![pusname isEqualToString:@"提交资料"])
    {
        self.textview.hidden=YES;
        [self.diview setFrame:CGRectMake(self.diview.frame.origin.x, self.diview.frame.origin.y-self.textview.frame.size.height, self.diview.frame.size.width, self.diview.frame.size.height)];
        
       
    }
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
    [titleLabel setTextColor:[UIColor whiteColor]];
    [titleLabel setTextAlignment:NSTextAlignmentCenter];
    titleLabel.font = [UIFont boldSystemFontOfSize:16];
    titleLabel.text = pusname;
    self.navigationItem.titleView= titleLabel;
    [self.image1 addimageViewController:self];
    [self.image2 addimageViewController:self];
    UIButton *leftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 12, 20)];
    [leftButton addTarget:self action:@selector(leftDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
    [leftButton setImage:[UIImage imageNamed:@"广告发布返回键"] forState:UIControlStateNormal];
    UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = leftBarButton;
  
    
    UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 44)];
    [rightButton addTarget:self action:@selector(rightDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
    [rightButton setImage:[UIImage imageNamed:@"电话"] forState:UIControlStateNormal];
    UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem = rightBarButton;
    
   
    if(OSVersionIsAtLeastiOS7>=7.0)
    {
        self.automaticallyAdjustsScrollViewInsets=NO;
    }
    
//    _agImage.userInteractionEnabled=YES;
//    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(addag:)];
//    [_agImage addGestureRecognizer:tap];
    
}


- (void)leftDrawerButtonPress:(UIButton *)but
{
    if([UIDevice currentDevice].systemVersion.floatValue > 6.5)
    {
        [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];
    }
    else
    {
        [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    }
    
//    [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)rightDrawerButtonPress:(UIButton *)but
{
    
}


- (IBAction)butYesNo:(UIButton *)sender {
    sender.selected= sender.selected?NO:YES;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
